package is2.misc.pipeAndFilter;

public class FilterProcess<A, B> implements Runnable
{
	InPipeConnector<A> inPipe; 
	OutPipeConnector<B> outPipe;
	Filter<A, B> filter;
	
	public FilterProcess(Filter<A, B> f, InPipeConnector<A> in, OutPipeConnector<B> out)
	{
		inPipe = in;
		outPipe = out;
		filter = f;
		
	}
	
	public void run()
	{
		
		while (true)
		{
		
			try {
				A msjOrigen = inPipe.Take();
				B msjDestino = filter.filter(msjOrigen);
				outPipe.Put(msjDestino);
				
			} catch (Exception e) {
				System.out.println(e.toString());
			}

		}

	}
	
	
}
